using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Sec_Administrators;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
using BusinessObjects;
using BussinessObjects.BO_Actions.Sec_Administrators;
using BussinessObjects.BO_Actions;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Sec_Administrators
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOSec_Administrators_Select_All action = new BOSec_Administrators_Select_All();
                usp_Sec_Administrators_Select_All entity = new usp_Sec_Administrators_Select_All();
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectGroup(int status, int group_id, int start, int maxrecord)
        {
            try
            {
                BOSec_Administrators_Select_Group action = new BOSec_Administrators_Select_Group();
                usp_Sec_Administrators_Select_Group entity = new usp_Sec_Administrators_Select_Group();
                entity.STATUS = status;
                entity.GROUP_ADMIN_ID = group_id;
                entity.STARTINDEX = start;
                entity.MAXRECORDS = maxrecord;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOSec_Administrators_Select_Top action = new BOSec_Administrators_Select_Top();
                usp_Sec_Administrators_Select_Top entity = new usp_Sec_Administrators_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int admin_id)
        {
            try
            {
                BOSec_Administrators_Search action = new BOSec_Administrators_Search();
                usp_Sec_Administrators_Search entity = new usp_Sec_Administrators_Search();
                entity.ADMIN_ID = admin_id;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string ForgotPassword(string user_name, string email, string password)
        {
            try
            {
                BOSec_Administrators_Forgot_Password action = new BOSec_Administrators_Forgot_Password();
                usp_Sec_Administrators_Forgot_Password entity = new usp_Sec_Administrators_Forgot_Password();
                entity.USER_NAME = user_name;
                entity.EMAIL = email;
                entity.PASS_WORD = password;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOSec_Administrators_Select_WithPaged action = new BOSec_Administrators_Select_WithPaged();
                usp_Sec_Administrators_Select_WithPaged entity = new usp_Sec_Administrators_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(string group_admin_id, string plus, string except, string full_name, string user_name, string pass_word, string phone_number, string address, string email, DateTime last_password_change, int login_falure_count, DateTime last_login_date, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOSec_Administrators_Insert action = new BOSec_Administrators_Insert();
                usp_Sec_Administrators_Insert entity = new usp_Sec_Administrators_Insert();
                entity.GROUP_ADMIN_ID = group_admin_id;
                entity.EXCEPT_ROLE = except;
                entity.PLUS_ROLE = plus;
                entity.FULL_NAME = full_name;
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.PHONE_NUMBER = phone_number;
                entity.ADDRESS = address;
                entity.EMAIL = email;
                entity.LAST_PASSWORD_CHANGE = last_password_change;
                entity.LOGIN_FALURE_COUNT = login_falure_count;
                entity.LAST_LOGIN_DATE = last_login_date;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(int admin_id, string group_admin_id, string plus, string except, string full_name, string user_name, string pass_word, string phone_number, string address, string email, DateTime last_password_change, int login_falure_count, DateTime last_login_date, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOSec_Administrators_Update action = new BOSec_Administrators_Update();
                usp_Sec_Administrators_Update entity = new usp_Sec_Administrators_Update();
                entity.ADMIN_ID = admin_id;
                entity.GROUP_ADMIN_ID = group_admin_id;
                entity.EXCEPT_ROLE = except;
                entity.PLUS_ROLE = plus;
                entity.FULL_NAME = full_name;
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.PHONE_NUMBER = phone_number;
                entity.ADDRESS = address;
                entity.EMAIL = email;
                entity.LAST_PASSWORD_CHANGE = last_password_change;
                entity.LOGIN_FALURE_COUNT = login_falure_count;
                entity.LAST_LOGIN_DATE = last_login_date;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int admin_id)
        {
            try
            {
                BOSec_Administrators_Delete action = new BOSec_Administrators_Delete();
                usp_Sec_Administrators_Delete entity = new usp_Sec_Administrators_Delete();
                entity.ADMIN_ID = admin_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int admin_id)
        {
            try
            {
                BOSec_Administrators_Restore action = new BOSec_Administrators_Restore();
                usp_Sec_Administrators_Restore entity = new usp_Sec_Administrators_Restore();
                entity.ADMIN_ID = admin_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Exist(string admin_name)
        {
            try
            {
                BOAdminExist action = new BOAdminExist();
                sp_IsExistsUser entity = new sp_IsExistsUser();
                entity.USERNAME = admin_name;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string ExistMail(string admin_name, string email)
        {
            try
            {
                BOAdminExistEmail action = new BOAdminExistEmail();
                sp_IsExistsMail entity = new sp_IsExistsMail();
                entity.USERNAME = admin_name;
                entity.EMAIL = email;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string GetPlusRole(string list_group_id)
        {
            try
            {
                BOSec_Administrators_Plus_Role action = new BOSec_Administrators_Plus_Role();
                usp_Sec_Administrators_Plus_Role entity = new usp_Sec_Administrators_Plus_Role();
                entity.GROUP_ID = list_group_id;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

